//和字符串处理相关的函数

#include <stdio.h>
#include <string.h>

//截取字符串尾部的空格
void Rtrim(char *string) {
	size_t len = 0;
	if(string == NULL)
		return;
	len = strlen(string);
	while(len > 0 && string[len-1] == ' ')
		string[--len] = 0;
	return;
}

//截取字符串首部的空格
void Ltrim(char *string) {
	size_t len = 0;
	len = strlen(string);
	char *tmp = string;
	if((*tmp) != ' ')
		return;
	while((*tmp) != '\0') {
		if((*tmp) == ' ') {
			tmp++;
			continue;
		}
		else
			break;
	}
	if((*tmp) == '\0') {
		//全空格字符串
		*string = '\0';
		return;
	}
	char *tmp2 = string;
	while((*tmp) != '\0') {
		*tmp2 = *tmp;
		tmp++;
		tmp2++;
	}
	(*tmp2) = '\0';
	return;
}
